<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html >
  <head>
  	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>FTP帐号创建系统</title>
	<link rel="stylesheet" href="<%=path %>/css/public.css" type="text/css"  />
	<link rel="stylesheet" href="<%=path %>/css/module.css" type="text/css"  />
	<link rel="stylesheet" href="<%=path %>/css/skin_blue.css" type="text/css"  />
	<script type="text/javascript" src="<%=path %>/js/json.js"></script>
	<script type="text/javascript" src="<%=path %>/js/util.js"></script>
	<script type="text/javascript" src="<%=path %>/js/jquery/jquery-1.8.0.min.js"></script>
	<script type="text/javascript">
		function init(){
			var data=getObjById('responseData').value;
			var objs=Ext.util.JSON.decode(data);
			for(var i=0;i<objs.length;i++){
				var objId=objs[i].id;
				getObjById(objId+'_v1').value=objs[i].v1;
				if(objId=='1'){
					getObjById(objId+'_v2').value=objs[i].v2;
					getObjById(objId+'_v3').value=objs[i].v3;
					getObjById(objId+'_v4').value=objs[i].v4;
				}
			}
		}
		function save(){
			if(getObjById('1_v1').value.length<1 ||getObjById('1_v2').value.length<1
					||getObjById('1_v3').value.length<1 ||getObjById('1_v4').value.length<1||
					getObjById('2_v1').value.length<1 ||getObjById('3_v1').value.length<1||getObjById('4_v1').value.length<1){

				alert('加 * 为必填项，该项值不能为空！');
				return ;
			}
			if(!checkMail(getObjById('1_v2').value)){
				alert('发送邮箱格式错误！');
				return ;
			}
			var objMail={};
			objMail.id='1';
			objMail.v1=getObjById('1_v1').value;
			objMail.v2=getObjById('1_v2').value;
			objMail.v3=getObjById('1_v3').value;
			objMail.v4=getObjById('1_v4').value;
			var objSaveDays={};
			objSaveDays.id='2';
			objSaveDays.v1=getObjById('2_v1').value;
			var objNormalSavePath={};
			objNormalSavePath.id='3';
			objNormalSavePath.v1=getObjById('3_v1').value;
			var objTempSavePath={};
			objTempSavePath.id='4';
			objTempSavePath.v1=getObjById('4_v1').value;
			var param={
				mail:objMail,
				saveDays:objSaveDays,
				normalSavePath:objNormalSavePath,
				tempSavePath:objTempSavePath
			};
			getObjById('btnSave').disable=true;
			$.ajax({
				type:'post',
				url:'<%=path %>/ftp!saveOtherSetting.action',
				data:'requestData='+Ext.util.JSON.encode(param),
				async:false,
				dataType: 'json',
				success:function(responseData){
					var data=responseData.result;
					if(data=="1"){
						alert(getSuccessMessage(true,null));
					}else{
						alert(getSuccessMessage(false,'发生未知错误'));
					}
					getObjById('btnSave').disable=false;
				}
			});
		}
		function testConnection(){
			
		}
	</script>
  </head>
  <body onload="init();">
  <input type="hidden" id="responseData" value="<s:property value="responseData" />">
  <div class="tab">
  <table width="100%"  border="0" class="formlist" cellpadding="0" cellspacing="0">
    <thead>
    	<tr>
        	<th colspan="4"><span>发送邮箱信息</span></th>
        </tr>
    </thead>
    <tfoot>
      <tr>
        <td colspan="4"><div class="bz">"<span class="red">*</span>"为必填项</div>
          <div class="btn">
           
            <button name="btnSave" id="btnSave" onclick="save();">保 存</button>
          </div>
        </td>
      </tr>
    </tfoot>
    <tbody>
      <tr>
        <th><span class="red">*</span>发送服务器</th>
        <td><input size="35" id="1_v1" class="text_nor"/></td>
        <th><span class="red">*</span>发送邮箱</th>
        <td><input size="35" id="1_v2" class="text_nor"/></td>
      </tr>
      <tr>
        <th><span class="red">*</span>用户名</th>
        <td><input size="35" id="1_v3"  class="text_nor"/></td>
        <th><span class="red">*</span>密码</th>
        <td><input type="password" size="35" id="1_v4"  class="text_nor"/></td>
      </tr>
      <!--  
      <tr>
      	<td colspan="4">
	      	<div class="btn">
	            <button name="btnTestConn" id="btnTestConn">测试连接</button>
	        </div>
      	</td>
      </tr>
      -->
    </tbody>
    <thead>
    	<tr>
        	<th colspan="4"><span>账号存放目录</span></th>
        </tr>
    </thead>
    <tbody>
      <tr>
        <th><span class="red">*</span>常规及长期账号</th>
        <td><input size="35" id="3_v1"  class="text_nor"/></td>
        <th><span class="red">*</span>临时账号</th>
        <td><input size="35" id="4_v1"  class="text_nor"/></td>
      </tr>
    </tbody>
    <thead>
    	<tr>
        	<th colspan="4"><span>常规账号有效期</span></th>
        </tr>
    </thead>
    <tbody>
      <tr>
        <th><span class="red">*</span>有效期(天)</th>
        <td><input size="35" id="2_v1"  class="text_nor"/></td>
      </tr>
    </tbody>
  </table>
  </div>

</body>
</html>
